// app.js
App({
  onLaunch() {
    let that = this;
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        wx.request({
          url: that.globalData.url+'/wxpai/login/wxLogin', 
          data: {
            code: res.code
          },
          header: {
            'content-type': 'application/x-www-form-urlencoded'
          },
          success (res) {
            if(res.data.code == 200){
              if(res.data.data.openid){
                wx.setStorageSync('openid', res.data.data.openid)
              }
            }
          }
        })
      }
    })
  },
  //是全局的数据存储
  globalData: {
    userInfo: null,
    url:'http://192.168.212.1:8099', 
    // url:'http://localhost:8099',
    openid:'',
  }
})
